/*
 * Copyright (c) 2006 - 2022, webrx.cn All rights reserved.
 *
 */
package cn.demo;

import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * <p>Project: app2022 - Stream8
 * <p>Powered by webrx On 2022-01-26 16:16:57
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Stream8 {
    public static void main(String[] args) {
        var is = Stream.of(
                new Student(1, "李四", "男", 18),
                new Student(22, "James Gosling", "男", 68),
                new Student(2, "张三", "男", 28),
                new Student(3, "王五", "男", 38),
                new Student(1, "李四", "男", 18),
                new Student(4, "李丽", "女", 25)
        );

        //分组groupingBy() 分组统计男多少人 女多少人
        //Map<String, Long> map = is.collect(Collectors.groupingBy(Student::getGender, Collectors.counting()));
        //System.out.println(map);

        //分组goupingBy() 组件学生信息 Map<String, List<Student>>
        //Map<String, List<Student>> mm = is.collect(Collectors.groupingBy(Student::getGender));
        //System.out.println(mm);

        //Map<String,List<String>>  mm 女 = [李丽],男=[李四,王五]

        //分区操作
        var mm = is.collect(Collectors.partitioningBy(e -> e.getName().startsWith("李")));
        System.out.println(mm);


    }
}
